odoo.define('maintenance_state.maintenance_state_kanban', function (require) {
    'use strict';
    // 引用
    var core = require('web.core');
    var Widget = require('web.Widget');
    var CrashManager = require('web.CrashManager');
    // 扩展Widget
    var MaintenanceStateWidget = Widget.extend({
        // 绑定事件
        events: {
            'click .my-button': function(){
                this.trigger_up('toggle_fullscreen');
            }
        },
        // 绑定模板
        template: 'Maintenance_State_Kanban',
        // 准备数据
        willStart: function(){
            var self = this;
            var fields = ["name", "work_duration_time", "state"];
            // 调用rpc获取模型数据
            var res = self._rpc({
                model: 'maintenance.state',
                method: 'search_read',
                fields: fields
            }).then(function (result) {
                // 当记录大于0时，绑定数据
                if(result.length > 0){
                    self.records = result;
                }else{
                    // 当记录小于等于0时，返回提示语
                    new CrashManager().show_warning({data: {
                        exception_type: "没有记录",
                        message: "暂时没有模型记录，请自去创建！"
                    }});
                }
            });
            return $.when(this._super.apply(this, arguments), res);
        },
    });
    //  通过core.action_registry.add(tag,函数名) 注册到odoo动作中
    core.action_registry.add('maintenance.state.kanban', MaintenanceStateWidget);
    
    return MaintenanceStateWidget;
});